package com.ibiaoke.boss.controller;


import com.ibiaoke.common.response.Res;
import com.ibiaoke.order.entity.GoodsRush;
import com.ibiaoke.order.service.GoodsRushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 限时抢购
 */
@Controller
public class GoodsRushController {
    @Autowired
    private GoodsRushService goodsRushService;

    /**
     * 查询进行中的抢购活动
     * @param goodsId
     * @return
     */
    @RequestMapping("/listValidRush")
    @ResponseBody
    public Res listValidRush(Integer goodsId) {
        List<GoodsRush> goodsRushes = goodsRushService.listValidRush(goodsId);
        return Res.create().addResponse("goodsRushes", goodsRushes);
    }

    /**
     * 查询所有未过期的抢购活动
     * @return
     */
    @RequestMapping("/listRush")
    @ResponseBody
    public Res listRush() {
        List<GoodsRush> goodsRushes = goodsRushService.listRush();
        return Res.create().addResponse("goodsRushes", goodsRushes);
    }
}
